# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Maintainer: T.J. Townsend <blakkheim@archlinux.org>
# Contributor: Markus Weimar <mail@markusweimar.de>

_pkgbase='iosevka'
_type='ttc'
pkgbase="${_type}-${_pkgbase}"
pkgname=(
    "${pkgbase}" "${pkgbase}-aile" "${pkgbase}-curly" "${pkgbase}-curly-slab" "${pkgbase}-etoile" "${pkgbase}-slab"
    "${pkgbase}-ss01" "${pkgbase}-ss02" "${pkgbase}-ss03" "${pkgbase}-ss04" "${pkgbase}-ss05" "${pkgbase}-ss06"
    "${pkgbase}-ss07" "${pkgbase}-ss08" "${pkgbase}-ss09" "${pkgbase}-ss10" "${pkgbase}-ss11" "${pkgbase}-ss12"
    "${pkgbase}-ss13" "${pkgbase}-ss14" "${pkgbase}-ss15" "${pkgbase}-ss16" "${pkgbase}-ss17" "${pkgbase}-ss18"
    )
pkgver=22.0.0
pkgrel=1
pkgdesc='Typeface family designed for coding, terminal use and technical documents.'
arch=('any')
url='https://typeof.net/Iosevka/'
license=('custom:OFL')
source=("${pkgbase}-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-${pkgver}.zip"
        "${pkgbase}-aile-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-aile-${pkgver}.zip"
        "${pkgbase}-curly-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-curly-${pkgver}.zip"
        "${pkgbase}-curly-slab-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-curly-slab-${pkgver}.zip"
        "${pkgbase}-etoile-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-etoile-${pkgver}.zip"
        "${pkgbase}-slab-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-slab-${pkgver}.zip"
        "${pkgbase}-ss01-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss01-${pkgver}.zip"
        "${pkgbase}-ss02-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss02-${pkgver}.zip"
        "${pkgbase}-ss03-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss03-${pkgver}.zip"
        "${pkgbase}-ss04-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss04-${pkgver}.zip"
        "${pkgbase}-ss05-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss05-${pkgver}.zip"
        "${pkgbase}-ss06-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss06-${pkgver}.zip"
        "${pkgbase}-ss07-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss07-${pkgver}.zip"
        "${pkgbase}-ss08-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss08-${pkgver}.zip"
        "${pkgbase}-ss09-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss09-${pkgver}.zip"
        "${pkgbase}-ss10-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss10-${pkgver}.zip"
        "${pkgbase}-ss11-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss11-${pkgver}.zip"
        "${pkgbase}-ss12-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss12-${pkgver}.zip"
        "${pkgbase}-ss13-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss13-${pkgver}.zip"
        "${pkgbase}-ss14-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss14-${pkgver}.zip"
        "${pkgbase}-ss15-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss15-${pkgver}.zip"
        "${pkgbase}-ss16-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss16-${pkgver}.zip"
        "${pkgbase}-ss17-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss17-${pkgver}.zip"
        "${pkgbase}-ss18-${pkgver}.zip::https://github.com/be5invis/Iosevka/releases/download/v${pkgver}/${pkgbase}-ss18-${pkgver}.zip"
        "${pkgbase}-${pkgver}-${pkgrel}-LICENSE.md::https://raw.githubusercontent.com/be5invis/Iosevka/v${pkgver}/LICENSE.md")
b2sums=('dc1041f243991996913b4404a05c83d181a41c82cb38e055b8aa612f5fea08c84b0af9916a010939ae7f63b9ac28b1ca6fe2ccbddc1623a057fbea851c46d0dd'
        '942631e99c768eeb7cef4a70e9c40d9c8e41a3d83e695fb3a809f00c250f371e393d727afaf251ae1fd5f5f08b0c323a631c8e99b668195abcd429b8ea623600'
        '7f36fd57a90e894fbe674510d3ac5f0560f47acc5b367eb1828c6c5ffa4bdfe99996298f08ec6bb968a40ff909f829a58048984a464cd4b4b950e34f4102a76d'
        'e6ee48fe44d725624acc03ac20a6084a0d11e86a985cb5994542079bc744edd623720a29aff3f3c2e8e950bb0940bdcbd6c322bae7dea4bc1469d66efe92b13a'
        'a02c93ad42f48823d1433586c338d1af4d119a70af5bbcf1cab3ffade49d6b5cfe78fae2be125758b154ef3abacb5f0a76a7300930a63a8d6ae27be3ef4a37d1'
        '335e4b9f387eccea1fdfd47c447ea9fbd700b46e5831b75329fdab56fa9c1fc95b9411dc9c6948fb42ebd526563c279a4186dba323f4c9881222106749588560'
        '98ad7fd1b40663c02c34c9f9c166fea3d94b4398272cbfbe2b23b48f992f22fab14e6a1b8300354d99512ba9ea6c32dc3320e709b4227790d9963537588a039c'
        'c9c044e8a3d8a3bef1dd83207a0fad1d0b74b90f5d93182aac8ab0f4dbdaf9b17bd335607aaf5c22192e304f321d7fe860c688ddf09c8cf049a30aa6bb2b5db0'
        'e90ec5c11723e6b3757d1f7279f619a59f32e72943d936927063885c5b0148d7725c8b39a33011a7fc7654fcbed32049dbcb1250d0f16317295fa1c401541909'
        'fd8b8357a9b370de36c3f893a85d622e2d23320c70c0d13ad1736404703634f2c025dcb4203c05871cfc2ad79da0e3f526a3b931f17740140f73a0a6cf5b3a4f'
        'e4bd597b3e2cd643a66641bab5b2001aafd0ad400a48c2fd97f993838ad5c5dad8fc0a71c00133116c0f52947954e06918871077eea84fcba13f12cb1b358c7f'
        '3112d1bc3c36bfdd8966920bd6cc17c520fda06fe39b0afd08f15dfe69e3eeb408ae07de62c33d9820e3131364637277325afb0bbfa806eef84d6266ac13b614'
        '33d9d24daba8ad6a29bf311cfa15895a7461bc94937f584fce7bb5cc3656ac304993ae0df4171c7882b83c8f1ee8bb6f7326661a30001bb6288edd48a3d90195'
        'd64f6d90d79dc34867dc26e41fe7d61230fb64d1cbb907ccb74068b27c9238a177ac30e2916b1b5ef68163276c64201dfb8db48e506e6b28efe9b361a892a8f2'
        '14b2f6a8eaa7ba98139a7f5dff7fb15c3c255164031af37f7d224ca5819213890322a79ba73e1f94d183bb95ae32f687a12dedce0f4faf92fcef3b6c7b9fe6f0'
        'c60b4a977c67783d63180a2ea8bcf8580e34bbf766c98c6a137c2a08b4f8a63838f7dbbb03b1223491228b3bf330e68d7cd07211e273b7155346bf9efed35f6d'
        '709ea559b6e6cb45774533e8c5dabe102a14240d08e9e9a8e79c9f3b7f94a5e44abd833b556dd570e78b1130c45fd9a79b540d2895772c42940e76845949d059'
        '3b9c8f44a3bfea7f040109e57d8e0f9dad82a3d9e13a5c5bfc15617853935151f52182186e9e78826b38711d1ca3da3d17a608d329dfb3200f742e0ebbd8f27d'
        '2ed02fe7328cd747a66bed27de218513f5a80a26d121a7219866d796246b1ef7edcb292ec99e3dec2ca999598d0915cd29c1e02dd3ec3e8bd87e49724a400c14'
        '6ca01ff079cbdaf46cf3eadd777bbecb4f971c194ca25b4679bdcad9e1e3b1d2e3e02297fd6e793c1655fd224400e6d03e9ccad753748c9020b8d4e7bcd520f4'
        'ea2ecb635f17c9dace1c2f3c83768d6d8486f460899f0c8ed3666156fdc4b389f1ee37c65974e91dd579533a878bd160b37911e51a5b0ef0d4436c4e48001b38'
        '5a51e958d516c452ab8e63237042ba657f512aeb5a1cf2bb435fff6ea55fccbfdf3ddb8b33ccdcb22e17de7bcc67ed8f12871ad629d13639ede7ffe309b444ad'
        '9f4de2c98fc748f9959c5ba259eca5970451a3554725d7644837c82bf5b0b30bb3d9626c102a06db9daa463f222827a72449fcaa00d9853a2dc552d37e2b6f54'
        '520e75675aa1ecdf307bbdc0dd9879d598768b364df068d05ae2bb7f3e5934f3a42b4a4eefb6411afd6d6cd834409cd6618918aff634397aa553ab499581817b'
        'c8d1b8e38801d7c1645eb250bc36922b7286b60d96be99f0bed2ce82939d299b343cca4a5767d2c1a1f11226326009828b49a11ce0ced9682af53e44a8afbc28')



function _package() {
    cd "${srcdir}/"
    local pkgnm="${1}"
    local fontname="${pkgnm#${_type}-}"
    local fontvar="${pkgnm#${pkgbase}-}"
    fontvar="${fontvar^}"
    install -d "${pkgdir}"/usr/share/fonts/TTF
    install -m644 "${fontname}"-*.ttc "${pkgdir}"/usr/share/fonts/TTF/
    install -d "${pkgdir}"/usr/share/licenses
    if [[ "${pkgnm}" == "${pkgbase}" ]]; then
        rm -rf "${pkgdir}/usr/share/fonts/TTF"/*{aile,curly,etoile,slab,ss}*
    else
        if [[ "${pkgnm}" == "${pkgbase}-curly" ]]; then
            rm -rf "${pkgdir}/usr/share/fonts/TTF"/*curly-slab*
        fi
        if [[ "${pkgnm}" == "${pkgbase}-curly-slab" ]]; then
            pkgdesc+=" (Curly Slab variant)"
        else
            pkgdesc+=" (${fontvar} variant)"
        fi
    fi
    install -D -m644 "${pkgbase}-${pkgver}-${pkgrel}-LICENSE.md" "${pkgdir}/usr/share/licenses/${pkgnm}/LICENSE.md"
}

for _pkgname in ${pkgname[@]}; do
    eval "function package_$_pkgname() { _package $_pkgname; }"
done
